{{extend './common/layout.html'}}

{{block 'main'}}
<!-- 头部 -->
{{include './common/header.html'}}
<!-- /头部 -->
<!-- 主体内容 -->
<div class="content">
    <!-- 侧边栏 -->
    {{include './common/aside.html'}}
    <!-- 侧边栏 -->
    <div class="main">
        <!-- 分类标题 -->
        <div class="title">
            <h4>文章</h4>
            <span>找到1篇文章</span>
            <a href="article-edit" class="btn btn-primary new">发布新文章</a>
        </div>
        <!-- /分类标题 -->
        <!-- 内容列表 -->
        <table class="table table-striped table-bordered table-hover custom-table">
            <thead>
                <tr>
                    <th>ID</th>
                    <th>标题</th>
                    <th>发布时间</th>
                    <th>作者</th>
                    <th>操作</th>
                </tr>
            </thead>
            <tbody>
                {{each articledata.records}}
                <tr>
                    <td>{{@$value._id}}</td>
                    <td>{{$value.title}}</td>
                    <td>{{dataformat($value.publishDate,'yyyy-mm-dd')}}</td>
                    <td>{{$value.author.username}}</td>
                    <td>
                        <a href="article-edit" class="glyphicon glyphicon-edit"></a>
                        <i class="glyphicon glyphicon-remove" data-toggle="modal" data-target=".confirm-modal"></i>
                    </td>
                </tr>
                {{/each}}
                
            </tbody>
        </table>
        <!-- /内容列表 -->
        <!-- 分页 -->
        <ul class="pagination">
            {{if articledata.page>1}}
                <li>
                    <a href="/admin/article?page={{articledata.page-1}}">
                        <span>&laquo;</span>
                    </a>
                </li>
            {{/if}}
           
            {{each articledata.display}}
            <li><a href="/admin/article?page={{$value}}"  {{$value==articledata.page?'style =background:darkgray':''}}>{{$value}}</a></li>
            {{/each}}
            {{if articledata.page < articledata.pages}}
                <li >
                <a href="/admin/article?page={{articledata.page+1}}">
                    <span>&raquo;</span>
                </a>
            </li>
            {{/if}}
            
        </ul>
        <!-- /分页 -->
    </div>
</div>
<!-- /主体内容 -->
<!-- 删除确认弹出框 -->
<div class="modal fade confirm-modal">
    <div class="modal-dialog modal-lg">
        <form class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"><span>&times;</span></button>
                <h4 class="modal-title">请确认</h4>
            </div>
            <div class="modal-body">
                <p>您确定要删除这篇文章吗?</p>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <input type="submit" class="btn btn-primary">
            </div>
        </form>
    </div>
</div>
<!-- /删除确认弹出框 -->
{{/block}}